
var 华为账号;
var coin;
var 花币领取数量 = 0;


launchApp("设置")
if (text("华为帐号、付款与账单、云空间等").findOne(20000)) {

    click("华为帐号、付款与账单、云空间等");
    }
console.log("打开个人中心");
sleep(10000)
华为账号 = id("account_name").findOne().text();
console.log(华为账号);
coin = id("account_coin_number").findOne();
花币领取数量 = (parseFloat(coin.text()) - 花币领取数量).toFixed(2);
var x = coin.bounds().centerX()
var y = coin.bounds().centerY()
console.log("花币数量" + coin.text());
click(x, y);
sleep(2000);

var 领取 = id("hcoin_receive_layout").findOne(10000);

if (领取) {
    console.log("找到领取按钮");
    领取.click();
    sleep(3000);
    var 领取 = text("领取").find();
    while (领取.length > 1) {
        text("领取").click();
        sleep(500);
        click("确定");
        sleep(2000)
        领取 = text("领取").find();
    }

}
launchApp("设置")
if (text("华为帐号、付款与账单、云空间等").findOne(20000)) {

    click("华为帐号、付款与账单、云空间等");
    }
console.log("打开个人中心");
sleep(10000)

coin = id("account_coin_number").findOne();
花币领取数量 = (parseFloat(coin.text()) - 花币领取数量).toFixed(2);



微信通知(华为账号, coin, 花币领取数量)



function 微信通知(华为账号, coin, 花币领取数量) {
    var wxtxt = 华为账号 + " 花币余额：" + coin.text() + " 领取花币数量：" + 花币领取数量;
    console.log(wxtxt);
    var getTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wwdd06640f29b4ee1a&corpsecret=aDR2ejeBEexnfrL9857hcivIHxTNtNUBvljGPiMUhaw";
    var resp = http.post(getTokenUrl, {});
    var token = resp.body.json()["access_token"];
    var sendMsgUrl = "https://qyapi.weixin.qq.com//cgi-bin/message/send?access_token=" + token;
    res = http.postJson(sendMsgUrl, {
        "touser": "@all",
        "msgtype": "text",
        "agentid": "1000007",
        "text": { "content": wxtxt }
    });
}
